/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;


import dao.TurmasDAO;
import dominio.Professores;
import dominio.Turmas;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import javax.faces.bean.ManagedBean; 
import javax.faces.bean.RequestScoped;
import javax.faces.model.SelectItem;
import util.ControleAcesso;

/**
 *
 * @author calistrato
 */
@ManagedBean(name = "centroBean")
@RequestScoped
public class CentroBean {
//
    private Professores professor;
    private Set<Turmas> turmas;
    private Turmas turma;
   
    
    public CentroBean() {
        professor = null; //
        professor=new Professores();
        ControleAcesso controle = new ControleAcesso();
        professor = controle.retornaLogado();
    }

    public List<SelectItem> getTurmas() {
        List<SelectItem> toReturn = new LinkedList<>();
       
        List<Turmas> l = new ArrayList();
        
        l.addAll(new TurmasDAO().getTurmasProfessor("2014", professor));
        Collections.sort(l);
        
        for (Turmas t : l) {
            toReturn.add(new SelectItem(t, t.getNomeTurma()));
        }
        return toReturn;
    }

    public void setTurmas(Set<Turmas> turmas) {
        this.turmas = turmas;
    }

    public Turmas getTurma() {
        return turma;
    }

    public void setTurma(Turmas turma) {
        this.turma = turma;
    }

    
    public Professores getProfessor() {
        return professor;
    }

    public void setProfessor(Professores professor) {
        this.professor = professor;
    }

    
}
